package com.smarkparking.tool;

import java.util.Date;

/**
 * @author 刘涛
 * @create 2021/11/20 17:22
 * 计算金额
 */
public class Price {
    /**
     * 根据小时差计算金额
     *
     * @param oldTime 初始时间
     * @param newTime 现在时间
     * @param price   每小时价格
     * @return 总金额
     */
    public static Double HPrice(Date oldTime, Date newTime, Double price) {
        long fromTime = oldTime.getTime();
        long toTime = newTime.getTime();
        Double newPrice = (double) (((toTime - fromTime) / (1000 * 60 * 60)) * price);
        return newPrice;
    }
}
